//
//  ResidenceHeaderView.m
//  Base_App
//
//  Created by Yutian Duan on 2019/6/11.
//  Copyright © 2019年 Wanwin. All rights reserved.
//

#import "ResidenceHeaderView.h"
#import "ResidenceUnLoginView.h"
#import "ResidenceLoginView.h"

@interface ResidenceHeaderView ()

//@p
@property (nonatomic, strong) ResidenceUnLoginView *unloginHeadView;

@property (nonatomic, strong) ResidenceLoginView *loginHeadView;

@end

@implementation ResidenceHeaderView

- (ResidenceUnLoginView *)unloginHeadView {
  if (!_unloginHeadView) {
    _unloginHeadView = [[ResidenceUnLoginView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    [self addSubview:_unloginHeadView];
    [_unloginHeadView.loginButton addTarget:self action:@selector(goLoginVC) forControlEvents:UIControlEventTouchUpInside];
    [_unloginHeadView.registButton addTarget:self action:@selector(goRegistVC) forControlEvents:UIControlEventTouchUpInside];

    
  }
  return _unloginHeadView;
}

- (ResidenceLoginView *)loginHeadView {
  if (!_loginHeadView) {
    _loginHeadView = [[ResidenceLoginView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    [self addSubview:_loginHeadView];
    
  }
  return _loginHeadView;
}

- (instancetype)initWithFrame:(CGRect)frame {
  self = [super initWithFrame:frame];
  if (self) {
    
  }
  return self;
}

- (void)reloadHead {
  
  if ([ToolsServer sharedInstance].isLoginApp == YES) {
    _unloginHeadView.hidden = YES;
    self.loginHeadView.hidden = NO;
    [self.loginHeadView setupData];
    
    self.yt_height = self.loginHeadView.yt_bottom;
  } else {
    self.unloginHeadView.hidden = NO;
    _loginHeadView.hidden = YES;
    self.yt_height = self.unloginHeadView.yt_bottom;
  }

}

- (void)goLoginVC {
  if ([self.delegate respondsToSelector:@selector(loginClick)]) {
    [self.delegate loginClick];
  }
}

- (void)goRegistVC {
  if ([self.delegate respondsToSelector:@selector(goRegistVC)]) {
    [self.delegate registClick];
  }
}

@end
